import {
  createRouter,
  createWebHistory,
  createWebHashHistory
} from "vue-router"
import storeIndex from "@/store/index.js";

const routes = [
  {
    path: '/',
    name: 'home',
    alias: ['/index', '/home'],
    component: () => import(/* webpackChunkName: 'vite' */ '@/views/home.vue'),
  },
  {
    path: '/aaa',
    name: 'aaa',
    component: () => import(/* webpackChunkName: 'vite' */ '@/views/aaa.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/provide',
    name: 'provide',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/provide/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/jsx',
    name: 'jsx',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/jsx/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/prop_emit',
    name: 'prop_emit',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/prop_emit/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/hook',
    name: 'hook',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/hook/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/excel',
    name: 'excel',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/excel/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/html2pdf',
    name: 'html2pdf',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/html2pdf/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
  {
    path: '/editor',
    name: 'editor',
    component: () =>
      import(/* webpackChunkName: 'vite' */ '@/views/editor/index.vue'),
    meta: {
      keepAlive: true,
    },
  },
]
const router = createRouter({
  // history: createWebHistory(),
  history: createWebHashHistory(),
  routes
})

router.beforeEach((to, from, next) => {
    console.log('路由拦截 to', to)
    console.log('路由拦截 storeIndex().aaa.$state', storeIndex().aaa.$state);		
    next();
});

export default router